using System.ComponentModel.DataAnnotations;
using System.Data.Entity.ModelConfiguration;
using System.Data.Entity.ModelConfiguration.Configuration;
using SapaFinance.Domain.Model;

namespace SapaFinance.Domain.EntityFramework
{
    internal class MoneyConfiguration : EntityTypeConfiguration<Money>
    {
        public MoneyConfiguration()
        {
            ToTable(typeof(Money).Name.ToLower());
            HasKey(x => x.UID);//.HasEntitySetName(typeof(AbstractEntity).Name);
            Property(x => x.UID).HasColumnName("id").HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
            Property(x => x.Amount).HasColumnName("paymentamount").IsRequired();
            HasRequired(p => p.Currency).WithMany().Map(m => m.MapKey("currencyid")).WillCascadeOnDelete(false);
        }
    }

}